Skip to content

tools: auto fix custom eslint rule for prefer-assert-methods.js - #16652

Closed
shobhitchittora wants to merge 2 commits into
nodejs:masterfrom
shobhitchittora:pref-assert-methods-eslint-fixer
Closed

tools: auto fix custom eslint rule for prefer-assert-methods.js#16652
shobhitchittora wants to merge 2 commits into
nodejs:masterfrom
shobhitchittora:pref-assert-methods-eslint-fixer

Conversation

@shobhitchittora

@shobhitchittora shobhitchittora commented Oct 31, 2017

Copy link
Copy Markdown
Contributor

This adds eslint fixer for auto-fixing the usage of assert operators. Also adding fileoverview for the perfer-assert-methods.js file.

For example the fixer change this assert(obj.value !== 9); to assert.notStrictEqual(obj.value, 9);

Refs: #16636

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
  • modify tests
Affected core subsystem(s)

Tools

@nodejs-github-bot nodejs-github-bot added the tools Issues and PRs related to the tools directory. label Oct 31, 2017
@shobhitchittora

ghost commented Nov 2, 2017

Copy link
Copy Markdown
Contributor Author

Hi @apapirovski. Can you also review this one? Thanks in advance.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM but it should be extended to assert.ok() as assert() is actually just the alias.

@addaleax

ghost commented Nov 30, 2017

Copy link
Copy Markdown
Member

@apapirovski

ghost commented Dec 9, 2017

Copy link
Copy Markdown
Contributor

ping @shobhitchittora — would you like to follow up on this? There's a bit of feedback here from @BridgeAR.

@apapirovski apapirovski added the wip Issues and PRs that are still a work in progress. label Dec 9, 2017
@shobhitchittora

ghost commented Dec 10, 2017

Copy link
Copy Markdown
Contributor Author

@apapirovski @BridgeAR extended for assert.ok. Please review.

ghost Dec 10, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not prefer assert.ok over assert. Both should be fine out of my perspective.

ghost Dec 10, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here. What did you mean when you said extend for assert.ok()?

ghost Dec 10, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general assert() should be treated identical to assert.ok(). And I meant the tests should be extended to test for both. Before I commented there were only tests for assert().

ghost Dec 10, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying this. I'll revert the added invalid test for assert(val).

ghost Dec 10, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@shobhitchittora
shobhitchittora force-pushed the pref-assert-methods-eslint-fixer branch from 246c566 to 74b89ca Compare December 10, 2017 06:41

ghost Dec 10, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be wrong but I think the idea was that assert(foo != bar) should yield the same as assert.ok(foo != bar). Since the former is an alias for the latter. That is, they should both report an error.

(I realize that might be modifying the current rule and is somewhat outside of the scope of the original work.)

ghost Dec 10, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would indeed be nice but I guess it is best to keep that for a separate PR and I am actually about to improve the assert message for cases like that in #17581

1. Extends tests
2. Refactors code
3. Adds fixer

Refs: nodejs#16636
@shobhitchittora
shobhitchittora force-pushed the pref-assert-methods-eslint-fixer branch from 74b89ca to 16e64b5 Compare December 15, 2017 08:11
@shobhitchittora

ghost commented Dec 15, 2017

Copy link
Copy Markdown
Contributor Author

@BridgeAR @apapirovski Updated the PR as per the new implementation by @cjihrig.

@BridgeAR

ghost commented Jan 19, 2018

Copy link
Copy Markdown
Member

Mini-CI (enough for this test): https://ci.nodejs.org/job/node-test-commit-light/149/

@BridgeAR BridgeAR added author ready PRs with CI started, the required approvals, and no outstanding review comments. and removed wip Issues and PRs that are still a work in progress. labels Jan 31, 2018
@BridgeAR

ghost commented Feb 1, 2018

Copy link
Copy Markdown
Member

Landed in 2d6912a

@BridgeAR BridgeAR closed this Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants